package jym.tan.movielibrary.utils;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import jym.tan.movielibrary.constant.PropertiesConstant;
import jym.tan.movielibrary.logger.LibraryLogger;

public class PropertiesUtils {

	private static class LazyProperties {
		private static final Properties PROPERTIES;
		
		static {
			PROPERTIES = new Properties();
			try {
				loadProperties();
			} catch (Exception exception) {
				LibraryLogger.errorMessage(exception.getMessage());				
			}
		}
		
		private static void loadProperties() throws FileNotFoundException, IOException {
			PROPERTIES.load(LazyProperties.class.getResourceAsStream(PropertiesConstant.FILE_PATH));
		}
	}
	
	private static String getProperty(String key) {
		return PropertiesUtils.LazyProperties.PROPERTIES.getProperty(key);
	}
	
	public static String getAPIKey() {
		return getProperty(PropertiesConstant.API_KEY);
	}
	
	public static String getMovieSearchURL() {
		return getProperty(PropertiesConstant.MOVIE_SEARCH_URL);
	}
	
	public static String getMovieGetInfoURL() {
		return getProperty(PropertiesConstant.MOVIE_GET_INFO_URL);
	}
}
